/***************************************************************************
 *                                                                         *
 *   This file is part of the Fotowall project,                            *
 *       http://code.google.com/p/fotowall                                 *
 *                                                                         *
 *   Copyright (C) 2009 by Enrico Ros <enrico.ros@gmail.com>               *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#include "FrameFactory.h"
#include "EmptyFrame.h"
#include <QFile>
#include <QSettings>

Q_GLOBAL_STATIC(FrameFactory, d)
#define FRAME_DEF 0x0001
#define FRAME_NOFRAME 0x0003
#define DEFAULT_PICTURE_FRAME FRAME_DEF


Frame * FrameFactory::createFrame(quint32 frameClass)
{
    if (frameClass == Frame::NoFrame)
        return 0;
    else if (frameClass == FRAME_NOFRAME)
        return new EmptyFrame();
    else
        qWarning( "FrameFactory::createFrame: unknown frame for class %x, falling back to default", frameClass);
    return 0;
}

Frame * FrameFactory::defaultPanelFrame()
{
    return createFrame(d()->m_defaultPanel);
}

Frame * FrameFactory::defaultPictureFrame()
{
    return createFrame(d()->m_defaultPicture);
}

quint32 FrameFactory::defaultPanelClass()
{
    return d()->m_defaultPanel;
}

void FrameFactory::setDefaultPanelClass(quint32 frameClass)
{
    d()->m_defaultPanel = frameClass;
}

quint32 FrameFactory::defaultPictureClass()
{
    return d()->m_defaultPicture;
}

void FrameFactory::setDefaultPictureClass(quint32 frameClass)
{
    d()->m_defaultPicture = frameClass;
}

// class impl
FrameFactory::FrameFactory()
    : m_defaultPicture(DEFAULT_PICTURE_FRAME)
{
}

FrameFactory::~FrameFactory()
{
}
